﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR76Response", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR76Response))]
    public class RR76ResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR76Response clazz;
        
        public RR76ResponseSerializer(IRR76Response clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Isikupnimi");
            if (clazz.Isikupnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikupnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikupnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuenimi");
            if (clazz.Isikuenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuolek");
            if (clazz.Isikuolek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuolek))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuolek");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Kirjestaatus");
            if (clazz.Kirjestaatus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kirjestaatus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kirjestaatus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusugu");
            if (clazz.Isikusugu!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusugu))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusugu");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusynnikp");
            if (clazz.Isikusynnikp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusynnikp))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusynnikp");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusurmakp");
            if (clazz.Isikusurmakp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusurmakp))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusurmakp");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikukodak");
            if (clazz.Isikukodak!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukodak))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukodak");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikukodaknm");
            if (clazz.Isikukodaknm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukodaknm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukodaknm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusynnivald");
            if (clazz.Isikusynnivald!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusynnivald))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusynnivald");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusynnikoht");
            if (clazz.Isikusynnikoht!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusynnikoht))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusynnikoht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuvald");
            if (clazz.Isikuvald!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuvald))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuvald");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuelukoht");
            if (clazz.Isikuelukoht!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuelukoht))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuelukoht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("poiVeaKood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.PoiVeaKood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocVeaTekst");
            if (clazz.PocVeaTekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocVeaTekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocVeaTekst");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Isikupnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikupnimi");
                }
                clazz.Isikupnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikupnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikupnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikuenimi");
                }
                clazz.Isikuenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikuenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuolek") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikuolek");
                }
                clazz.Isikuolek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuolek")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikuolek", Reader.LocalName);
            }
            if (Reader.LocalName=="Kirjestaatus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Kirjestaatus");
                }
                clazz.Kirjestaatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Kirjestaatus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Kirjestaatus", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusugu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikusugu");
                }
                clazz.Isikusugu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusugu")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikusugu", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusynnikp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikusynnikp");
                }
                clazz.Isikusynnikp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusynnikp")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikusynnikp", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusurmakp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikusurmakp");
                }
                clazz.Isikusurmakp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusurmakp")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikusurmakp", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikukodak") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikukodak");
                }
                clazz.Isikukodak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukodak")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikukodak", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikukodaknm") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikukodaknm");
                }
                clazz.Isikukodaknm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukodaknm")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikukodaknm", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusynnivald") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikusynnivald");
                }
                clazz.Isikusynnivald = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusynnivald")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikusynnivald", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusynnikoht") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikusynnikoht");
                }
                clazz.Isikusynnikoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusynnikoht")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikusynnikoht", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuvald") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikuvald");
                }
                clazz.Isikuvald = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuvald")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikuvald", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuelukoht") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>Isikuelukoht");
                }
                clazz.Isikuelukoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuelukoht")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>Isikuelukoht", Reader.LocalName);
            }
            if (Reader.LocalName=="poiVeaKood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>poiVeaKood");
                }
                clazz.PoiVeaKood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("poiVeaKood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>poiVeaKood", Reader.LocalName);
            }
            if (Reader.LocalName=="pocVeaTekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR76Response>pocVeaTekst");
                }
                clazz.PocVeaTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocVeaTekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR76Response>pocVeaTekst", Reader.LocalName);
            }
        }
    }
}
